package com.example.myapplication;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;

import com.example.myapplication.bean.Weapon;

public class ShopActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_shop);
        //找到布局控件
        LinearLayout jinjian= (LinearLayout) findViewById(R.id.ll_jinjian);
        //处理点击事件，返回上一页，将数据带回
        jinjian.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                int data=100;//数据
                Weapon weapon=new Weapon(20,100,20);//将装备的属性封装成Weapon对象
                //将对象weapon。传递，按字节
                //类的序列化，将类的各个属性转换成byte[]
                Intent intent=new Intent();//把数据放intent
                intent.putExtra("data",weapon);//将对象放入intent
                setResult(2,intent);
                finish();//结束Activity，返回上一个Activty



            }
        });
    }
}
